
import store from '../../store/index';
let changeDialogState = function() {
  Object.getOwnPropertyNames(store.state.dialog).forEach(item => {
    let name = item;
    // name.charAt(0).toUpperCase() + name.slice(1);
    if (/^[A-Z]*$/.test(name)) {
      store.commit(`dialog/set${name}`, false);
    } else {
      // name.charAt(0).toUpperCase() + name.slice(1);
      if (name == '__ob__') {
        return false;
      } else {
        commitState(upperCase(name));
      }
      // store.commit(`dialog/${name}`, false);
    }
  });
  // store.commit('dialog/setScheduleDialog', false);
};

function upperCase(str) {
  return str.charAt(0).toUpperCase() + str.slice(1);
}

function commitState(val) {
  store.commit(`dialog/set${val}`, false);
}

export default changeDialogState;
